/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __PACT_TASKWIDGET_HDR__
#define __PACT_TASKWIDGET_HDR__

#ifdef WIN32
	// disable - decorated name length exceeded
	#pragma warning(disable:4503)
	// disable 'identifier' truncation warning
	#pragma warning(disable:4786)
#endif


#include <qdialog.h>
#include <qpushbutton.h>
//Added by qt3to4:
#include <QShowEvent>
#include <QKeyEvent>
#include <QHideEvent>
#include <QLabel>
#include <stdexcept>


class QLabel;
class QButtonGroup;
class Q3WidgetStack;


namespace pact{

	class TrialTask;


	/*!
	 * \struct atc::taskwidget_error
	 */
	struct taskwidget_error : public std::runtime_error{
		taskwidget_error(const std::string& msg) 
			:std::runtime_error(msg){}
	};


	/*!
	 * \class pact::TaskDialog
	 */
	class Dialog : public QDialog {
		Q_OBJECT

	public:
		Dialog( TrialTask *, const char * );
		~Dialog();

	public:
		void addWidget( QWidget * );
		void setInterval( unsigned int interval ) { _interval = interval; }
		void setSingleShot() { _sshot = true; }

		void setLocation( const std::string &location ) { _location = location; }

	public slots:
		void reset_timer();

	protected: // virtual

		void keyPressEvent( QKeyEvent * ); 
		void showEvent( QShowEvent * );
		void hideEvent( QHideEvent * );

	private:
		void log_state();

		void _setLocation();

	private slots:
		void process_stack();

	signals:
		void shown();
		void hidden();

	private:
		Q3WidgetStack   *_stack;
		int				_widgetNo;
		unsigned int	_interval;
		bool			_sshot;

		std::string     _location;
	};

	
	/*!
	 * \class pact::PushButton
	 */
	class PushButton : public QPushButton
	{
	public:

		PushButton(QWidget*, const char*);
		~PushButton();

	};

};

#endif
